﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
   public class TaiLieu_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable TaoBang(string sql)
       {
           return kn.taobang(sql);
       }
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_TaiLieu");
       }
       public int Insert(TaiLieu_Public maTaiLieu, TaiLieu_Public nhanDe, TaiLieu_Public phuDe, TaiLieu_Public tacGiaChinh, TaiLieu_Public dongTacGia, TaiLieu_Public nguoiBienDich, TaiLieu_Public tomTat, TaiLieu_Public lanXB, TaiLieu_Public namXB, TaiLieu_Public maNgonNgu, TaiLieu_Public maLinhVuc, TaiLieu_Public maTheLoai, TaiLieu_Public maNhaXB, TaiLieu_Public maNguonCung, TaiLieu_Public maVtri, TaiLieu_Public soTrang, TaiLieu_Public soLuong, TaiLieu_Public giaBia ,TaiLieu_Public ngayBienMuc, TaiLieu_Public trangThai,TaiLieu_Public maNhanVien)
       {
           int Npamater = 21;
           string[]name=new string[Npamater];
           object[] value = new object[Npamater];
           name[0] = "@MaTaiLieu";
           value[0] = maTaiLieu.MaTaiLieu;
           name[1] = "@NhanDe";
           value[1] = nhanDe.NhanDe;
           name[2] = "@PhuDe";
           value[2] = phuDe.PhuDe;
           name[3] = "@TacGiaChinh";
           value[3] = tacGiaChinh.TacGiaChinh;
           name[4] = "@DongTacGia";
           value[4] = dongTacGia.DongTacGia;
           name[5] = "@NguoiBienDich";
           value[5] = nguoiBienDich.NguoiBienDich;
           name[6] = "@TomTatNoiDung";
           value[6] = tomTat.TomTatNoiDung;
           name[7] = "@LanTaiBan";
           value[7] = lanXB.LanTaiBan;
           name[8] = "@NamXuatBan";
           value[8] = namXB.NamXuatBan;
           name[9] = "@MaNgonNgu";
           value[9] = maNgonNgu.MaNgonNgu;
           name[10] = "@MaLinhvuc";
           value[10] = maLinhVuc.MaLinhVuc;
           name[11] = "@MaTheLoai";
           value[11] = maTheLoai.MaTheLoai;
           name[12] = "@MaNhaXB";
           value[12] = maNhaXB.MaNhaXB;
           name[13] = "@MaNguonCung";
           value[13] = maNguonCung.MaNguonCung;
           name[14] = "@MaViTri";
           value[14] = maVtri.MaViTri;
           name[15] = "@SoTrang";
           value[15] = soTrang.SoTrang;
           name[16] = "@SoLuong";
           value[16] = soLuong.SoLuong;
           name[17] = "@GiaBia";
           value[17] = giaBia.GiaBia;
           name[18] = "@NgayBienMuc";
           value[18] = ngayBienMuc.NgayBienMuc;
           name[19] = "@TrangThaiDKCB";
           value[19] = trangThai.TrangThaiDKCB;
           name[20] = "@MaNhanVien";
           value[20] = maNhanVien.MaNhanVien;

           return kn.update("Insert_TaiLieu",name,value,Npamater);
       }
       public int Update(TaiLieu_Public maTaiLieu, TaiLieu_Public nhanDe, TaiLieu_Public phuDe, TaiLieu_Public tacGiaChinh, TaiLieu_Public dongTacGia, TaiLieu_Public nguoiBienDich, TaiLieu_Public tomTat, TaiLieu_Public lanXB, TaiLieu_Public namXB, TaiLieu_Public maNgonNgu, TaiLieu_Public maLinhVuc, TaiLieu_Public maTheLoai, TaiLieu_Public maNhaXB, TaiLieu_Public maNguonCung, TaiLieu_Public maVtri, TaiLieu_Public soTrang, TaiLieu_Public soLuong, TaiLieu_Public giaBia, TaiLieu_Public ngayBienMuc, TaiLieu_Public trangThai, TaiLieu_Public maNhanVien)
       {
           int Npamater = 21;
           string[] name = new string[Npamater];
           object[] value = new object[Npamater];
           name[0] = "@MaTaiLieu";
           value[0] = maTaiLieu.MaTaiLieu;
           name[1] = "@NhanDe";
           value[1] = nhanDe.NhanDe;
           name[2] = "@PhuDe";
           value[2] = phuDe.PhuDe;
           name[3] = "@TacGiaChinh";
           value[3] = tacGiaChinh.TacGiaChinh;
           name[4] = "@DongTacGia";
           value[4] = dongTacGia.DongTacGia;
           name[5] = "@NguoiBienDich";
           value[5] = nguoiBienDich.NguoiBienDich;
           name[6] = "@TomTatNoiDung";
           value[6] = tomTat.TomTatNoiDung;
           name[7] = "@LanTaiBan";
           value[7] = lanXB.LanTaiBan;
           name[8] = "@NamXuatBan";
           value[8] = namXB.NamXuatBan;
           name[9] = "@MaNgonNgu";
           value[9] = maNgonNgu.MaNgonNgu;
           name[10] = "@MaLinhvuc";
           value[10] = maLinhVuc.MaLinhVuc;
           name[11] = "@MaTheLoai";
           value[11] = maTheLoai.MaTheLoai;
           name[12] = "@MaNhaXB";
           value[12] = maNhaXB.MaNhaXB;
           name[13] = "@MaNguonCung";
           value[13] = maNguonCung.MaNguonCung;
           name[14] = "@MaViTri";
           value[14] = maVtri.MaViTri;
           name[15] = "@SoTrang";
           value[15] = soTrang.SoTrang;
           name[16] = "@SoLuong";
           value[16] = soLuong.SoLuong;
           name[17] = "@GiaBia";
           value[17] = giaBia.GiaBia;
           name[18] = "@NgayBienMuc";
           value[18] = ngayBienMuc.NgayBienMuc;
           name[19] = "@TrangThaiDKCB";
           value[19] = trangThai.TrangThaiDKCB;
           name[20] = "@MaNhanVien";
           value[20] = maNhanVien.MaNhanVien;

           return kn.update("Update_TaiLieu", name, value, Npamater);
       }
       public int Delete(TaiLieu_Public maTaiLieu)
       {
           int Npamater = 1;
           string[] name = new string[Npamater];
           object[] value = new object[Npamater];
           name[0] = "@MaTaiLieu";
           value[0] = maTaiLieu.MaTaiLieu;


           return kn.update("Delete_TaiLieu", name, value, Npamater);
       }
    }
}
